<?php include './function.php'; ?>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Demo</title>
        <link href="style.css" rel="stylesheet" type="text/css"/>
    </head>
    <style>

    </style>
    <body>
        <div class="wrapper">
            <?php
            $sql = 'select * from students';
            $students = query($sql);
            // var_dump($students);
            ?>
            <table>
                <p>Students</p>
                <tr>
                    <th>ID</th>
                    <th>Name</th> 
                    <th>Delete</th> 
                </tr>      
                <?php foreach ($students as $student): ?>
                    <tr>
                        <td><?php echo ($student['ID']); ?></td>
                        <td><?php echo ($student['Name']); ?></td>    
                        <td>
                            <form action="delete.php?ID=<?php echo $student['ID'] ?>" method="post">
                                <input type="submit" value="Delete">
                            </form>
                        </td>
                    </tr>
                <?php endforeach; ?>      
            </table>

            <form id="form1" name="form1" method="post" action="insert_stu.php">
                Name: <input type="text" name="basic_name2" id="textfield" />
                <input type="submit" name="button" id="button" value="Insert" />
            </form>
            <form id="form2" name="form2" method="post" action="updatestu.php">
                ID: <input type="text" name="id" id="textfield"/>
                Name: <input type="text" name="name" id="textfield" />
                <input type="submit" name="button" id="button" value="Update" />
            </form>

            <?php
            $sql = 'select * from staffs;';
            $staffs = query($sql);
// var_dump($staffs);
            ?>
            <table>
                <p>Staffs</p>
                <tr>
                    <th>ID</th>
                    <th>Name</th>    
                    <th>Delete</th> 
                </tr>      
                <?php foreach ($staffs as $staff): ?>
                    <tr>
                        <td><?php echo ($staff['ID']); ?></td>
                        <td><?php echo ($staff['Name']); ?></td> 
                        <td>
                            <form action="delete_1.php?ID=<?php echo $staff['ID'] ?>" method="post">
                                <input type="submit" value="Delete">
                            </form>
                        </td>
                    </tr>
                <?php endforeach; ?>
            </table> 
            <form id="form1" name="form1" method="post" action="insert_sta.php">
                Name: <input type="text" name="basic_name2" id="textfield" />
                <input type="submit" name="button" id="button" value="Insert" />
            </form>
        </div>
    </body>
</html>